﻿using System;
using System.Data;
using System.Collections.Generic;
using SERP.DAO;
namespace SERP.Controllers{
public class SalaryRulesControllerBase : Controller{
	public SalaryRulesControllerBase()
		: base()
	{
	}
	private static SalaryRulesDAO _Service; 
	public static SalaryRulesDAO Service{
		get{
			if(_Service==null)
				_Service = new SalaryRulesDAO();
			return _Service;
		}
		set{
			_Service = value;
		}
	}
    //Copy data from data row in grid to object
    public SalaryRulesEntity MapDataRowToObject(DataRow row){
		SalaryRulesEntity o = new SalaryRulesEntity();
		 o.RuleName=Convert.ToString(row["RuleName"]);
		 o.Note=Convert.ToString(row["Note"]);
		 if(!row.IsNull("Status"))
			o.Status=ConvertByte(row["Status"]);
		 if(!row.IsNull("FromDay"))
			o.FromDay=ConvertInt(row["FromDay"]);
		 if(!row.IsNull("ToDay"))
			o.ToDay=ConvertInt(row["ToDay"]);
		 if(!row.IsNull("SalaryRuleId"))
		    o.SalaryRuleId=(Int32)(row["SalaryRuleId"]);
		 return o;
    }
	//Copy data from object to data row in grid    
    public void MapObjectToDataRow(SalaryRulesEntity o,DataRow row){
		row["RuleName"]=o.RuleName;
		row["Note"]=o.Note;
		row["Status"]=o.Status;
		row["FromDay"]=o.FromDay;
		row["ToDay"]=o.ToDay;
		row["SalaryRuleId"]=o.SalaryRuleId;
    }
}
}
